<template>
  <div>
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" prop="order" width="50" />
      <el-table-column label="位置编号" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.placeNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="位置名称" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.placeName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="所属部门" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="负责人" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.headName || '-' }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="所属位置" align="center" min-width="130">
        <template slot-scope="scope">
          {{ ['室内位置', '室外位置'][scope.row.position] || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="建筑物名称" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.buildingName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="建筑物/位置坐标" align="center" min-width="130">
        <template slot-scope="scope">
          经度:{{ scope.row.longitude || '-' }}
          纬度:{{ scope.row.latitude || '-' }}
        </template>
      </el-table-column> -->
      <el-table-column label="备注" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.remark || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建部门" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" min-width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.createBy || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="220" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button v-hasPermi="['ledger_location_update']" size="small" type="primary" icon="el-icon-edit"
            @click="handleUpdate(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <template v-if="open">
      <AddLocation :title="title" :rowObj="rowObj"></AddLocation>
    </template>
  </div>
</template>

<script>
import { getplacelist } from "@/api/equipment/equipment.js";

export default {
  name: "Location",
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  components: {
    AddLocation: () => import('../form/addLocation.vue')
  },
  data () {
    return {
      // 遮罩层
      loading: true,
      opendetailed: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      dictdatalist: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层表格数据
      noticeList: [],
      // 是否显示弹出层
      open: false,
      title: '修改位置',
      rowObj: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'placeId',
        isAsc: 'desc'//倒叙
      },
    };
  },
  computed: {
  },
  created () {
    this.getList();
  },
  mounted () {
    // console.log(this.dict.type.sys_notice_status);
  },
  methods: {
    /** 查询列表 */
    async getList (value) {
      this.loading = true;
      let objects = value || {}
      let params = {
        ...this.queryParams,
        ...objects,
      }
      //  let data = await getdatalist({ dictType: 'base_unit' })
      //  this.dictdatalist=data.data
      getplacelist(params).then(response => {
        this.noticeList = response.data && response.data.map((item, index) => {
          return {
            ...item,
            order: index + 1
          }
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 修改按钮操作 */
    handleUpdate (row) {
      this.rowObj = row
      this.open = true
    },
  },
  filters: {
  }
};
</script>
<style lang="scss" scoped>
.red {
  color: red;
}
</style>